// pages/visitors/visitors.js
var app = getApp();
import api from "../../common/api.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    widthVi: 0,
    widthVis: 0,
    isContent: true,
    copyShowDialog: false,
    offoci: true,
    scene: app.globalData.scene,
    menuVisitor: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    //查询客源访客列表接口方法
    api.visiTorsList({
      page: '1',
      pageSize: '99999',
      houDelId: options.id,
    }, function (res) {
      let menuVisitor = res.data.content.rows;
      if (menuVisitor.length == 0) {
        that.setData({
          isContent: false,
          offoci: false,
        })
      } else {
        // = -1 说明找不到 就不显示公众号组件
        if ([1047, 1124, 1089, 1038, 1011, 1017].indexOf(that.data.scene) < 0) {
          //隐藏公众号组件·调整高度
          that.setData({
            offoci: false,
            widthVis: app.globalData.windowHeight
          })
        } else {
          //隐藏公众号组件
          that.setData({
            offoci: true,
            widthVis: app.globalData.windowHeight - 115
          })
        }
        that.setData({
          menuVisitor: menuVisitor,
          isContent: true
        })
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res.windowHeight)
        that.setData({
          widthVi: res.windowHeight
        })

      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  hcopyNickname: function (e) {
    var that = this;
    let hnickNames = e.currentTarget.dataset.nickname;
    wx.hideToast();
    that.setData({
      copyShowDialog: true
    })
    wx.setClipboardData({
      data: hnickNames,
      success(res) {
        wx.hideToast();
      }
    })
  },

  toggleCopyShowDialog: function () {
    var that = this;
    that.setData({
      copyShowDialog: false
    })
  },

  goCopy: function () {
    var that = this;
    that.setData({
      copyShowDialog: false
    })
  },

  success: function (e) {

  },

})